import sqlite3

conn = sqlite3.connect('../database.db')
conn.row_factory = sqlite3.Row

sql = 'select * from gate_pass_info_index'
result = conn.execute(sql).fetchall()
with open('C:/bangjiang/gate_pass_info_index', 'w', encoding='utf8') as f:
    for row in result:
        row = tuple(row)
        line = '{},{}\n'.format(row[0], row[1])
        f.write(line)